﻿@page "/component/common/flag"
<Pager DataSource="@(new List<string>(new[] {" Flag","Enumerable" }))">
    <Body>
<Header1 Divider>
    Flag
    <SubHeader>
        A flag is used to represent a political state.
    </SubHeader>
</Header1>

<PresentationPart Title="Flag">
    <RunTemplate>
        <Flag FlagType="Flag.Type.China" title="China"/>
        <Flag FlagType="Flag.Type.UnitedStates" title="USA"/>
        <Flag FlagType="Flag.Type.Brazil" title="Brazil"/>
    </RunTemplate>
    <CodeTemplate>
        @Code.GetCode(@"
```html
<Flag FlagType=""Flag.Type.China"" />
<Flag FlagType=""Flag.Type.UnitedStates"" />
<Flag FlagType=""Flag.Type.Brazil"" />
```
")
    </CodeTemplate>
</PresentationPart>
        <PresentationPart Title="Enumerable">
    <Description>
        Here is a demo to get all <code>Flag.Type</code> enum members.
    </Description>
    <RunTemplate>
            @Flags
    </RunTemplate>
    <CodeTemplate>
        @Code.GetCode(@"
```html
@Flags
```
```csharp
RenderFragment Flags = builder =>
{
    var flagList = Enum.GetNames(typeof(Flag.Type));
    var i = 0;
    foreach (var item in flagList)
    {
        builder.OpenComponent<Flag>(i);
        builder.AddAttribute(i + 1, nameof(Flag.FlagType), Enum.Parse<Flag.Type>(item));
        builder.CloseComponent();
        i++;
    }
};
```
")
    </CodeTemplate>
</PresentationPart>
    </Body>
</Pager>

@code{
    RenderFragment Flags = builder =>
    {
        var flagList = Enum.GetNames(typeof(Flag.Type));
        var i = 0;
        foreach (var item in flagList)
        {
            builder.OpenComponent<Flag>(i);
            builder.AddAttribute(i + 1, nameof(Flag.FlagType), Enum.Parse<Flag.Type>(item));
            builder.CloseComponent();
            i++;
        }
    };
}